home *** CD-ROM | disk | FTP | other *** search
/ Eagles Nest BBS 8 / Eagles_Nest_Mac_Collection_Disc_8.TOAST / Developer Environments / AAISProlog / Examples / print selection.p / print selection.p
Encoding:
Text File  |  1992-05-26  |  2.0 KB  |  57 lines  |  [TEXT/AIFC]

  1. /*
  2.  * print selection.p: Print Selection Command.
  3.  *
  4.  * Copyright, Â© 1992 Advanced A. I. Systems, Inc.
  5.  * All rights reserved.
  6.  * This file may not be copied or distributed without the 
  7.  * written permission of Advanced A. I. Systems, Inc.
  8.  *
  9. This file illustrates making a print selection menu command.  
  10. It uses the functions defined in ::Environment:printer.p.
  11.  
  12. Here, by using the modifier_keys function, we make this an option to the 
  13. print window command by checking for the shift key (or any other key you
  14. choose).  
  15.  
  16. However, Prolog cannot have a different name displayed when the shift key is
  17. depressed and the menu is selected.
  18.  
  19. You can also make another menu command:
  20. :- add_menu_command(file_menu, print_selection, "Print Selection…",
  21.     print_selection(active_window)).
  22.     
  23. You will need to define print_selection/1,  Also, you should also modify
  24. activate and deactivate for text_entry and text_entry_window
  25. to highlight this the same as open_selection is highlighted.  
  26.  
  27.  */
  28.  
  29. /*
  30.  * New version that checks for the shift key for selection printing.
  31.  * See warning above about menu command not being able to
  32.  *    display this command change when selected by the mouse.
  33.  * It is not possible with Prolog to have a menu item appear differently when
  34.  *    the shift key is or is not depressed.
  35.  */
  36. :- no_style_check different_file.
  37.  
  38. text_entry_window <- print_window(TEW) :-
  39.     active_object(TEW, TextEntry),
  40.     get_font(TextEntry, FontName, FontSize),
  41.     create(io_stream, Input ,TextEntry, read),
  42.     get_text_pos(TextEntry, FromLn, FromPos, ToLn, ToPos),
  43.     (modifier_keys(shift),(FromLn \= ToLn ; FromPos \= ToPos) ->
  44.         true
  45.     ;    fseek(Input, 0)    /* Only do this when printing the whole window */
  46.     ),
  47.     print_input_stream(Input, FontName, FontSize).
  48.  
  49. /*
  50.  * We do not need to define the shift-option-p key command.
  51.  * The menu key command will work with shift-option-p.
  52.  */
  53. :- error(2, "The Print Selection shift option
  54. has been successfully installed.
  55. You can now hold the shift key down while 
  56. selecting Print Window to do Print Selection.", _, _, _, _, _, _, _).
  57.